package com.clever.mall.controller;

import com.clever.mall.service.UploadService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @className UploadController
 * @date 2020/11/09 11:45
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/upload")
public class UploadController {
    @Resource
    UploadService uploadService;
    @RequestMapping(value = "/img",method = RequestMethod.POST )
    public String uploadImg(@RequestParam("img") MultipartFile multipartFile){
        String msg = "OK";
        try {
            String path = uploadService.uploadImg(multipartFile);
        } catch (IOException e) {
            msg = "error";
        }
        return msg;
    }

}
